package com.dwms.controller;

import com.dwms.entity.PageResponse;
import com.dwms.entity.QueryRequest;
import com.dwms.entity.Result;
import com.dwms.entity.oms.orderLog.request.OrderLogQueryRequest;
import com.dwms.entity.oms.orderLog.response.OrderLogResponse;
import com.dwms.feign.oms.OrderLogFeignClient;
import com.dwms.utils.WebUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName: OrderLogController
 * @Description: OrderLog
 * @Create 2025-10-11 22:44:55
 * @Author WH
 * @Since 1.0.0
**/
@Tag(name = "平台订单日志")
@RestController
@RequestMapping(value = "/plat/orderLog")
@RequiredArgsConstructor
public class OrderLogController {

    private final HttpServletRequest request;
    private final OrderLogFeignClient orderLogFeignClient;

    /**
     * 分页查询
     *
     * @param query
     *          查询参数
     * @return
     */
    @Operation(summary = "分页查询")
    @PostMapping("/findPage")
    public Result<PageResponse<OrderLogResponse>> findPage(@RequestBody OrderLogQueryRequest query) {
        WebUtil.getAdminRequest(request, query);
        return orderLogFeignClient.findPage(query);

    }

    /**
     *  根据ID查询
     *
     * @param query
     *          参数
     * @return
     */
    @Operation(summary = "根据ID查询")
    @PostMapping("/findById")
    public Result findById(@RequestBody QueryRequest query){
        WebUtil.getAdminRequest(request, query);
        return this.orderLogFeignClient.findById(query);
    }

    /**
     * 根据订单ID查询
     * @param query
     * @return
     */
    @Operation(summary = "根据订单ID查询")
    @PostMapping("/findByOrderId")
    public Result<List<OrderLogResponse>> findByOrderId(@RequestBody QueryRequest query) {
        WebUtil.getAdminRequest(request, query);
        return this.orderLogFeignClient.findByOrderId(query);
    }
}
